<%@page import="cdp.Compra"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="cdp.Cliente"%>
<%@page import="java.util.List"%>
<%@include file="../includes/topo.jsp" %>
<div id="content">
    <form action="Relatorio" method="post" class="f-wrap-1" id="formConsultarCliente">
        <input type="hidden" name="evento" id="evento" value="compraPesquisar">    
        Data: <input type="text" name="data" id="data" value="<%=(request.getParameter("data") == null) ? "" : request.getParameter("data")%>" /> <input type="submit" value="Pesquisar" /><br />
        <%
            List<Compra> list = (List<Compra>) request.getAttribute("listaCompras");
            if (list == null || list.isEmpty()) {
                out.print("<h3>Informe a data para pesquisar</h3>");
            } else {
        %>         
        <table class="table1">
            <thead>
                <tr>
                    <th colspan="5">Lista de Vendas</th>
                </tr>
            </thead>
            <tbody id="tb_conteudo">
                <tr>
                    <th>Cliente</th>
                    <th>Tipo Cliente</th>
                    <th>Produto</th>
                    <th>Valor total</th>
                    <th>Data da venda</th>
                </tr>
                <%
                    for (Compra compra : list) {
                %>
                <tr>
                    <th class='sub'><%=compra.getCliente().getNome()%></th>
                    <td><%=compra.getCliente().getTipoCliente()%></td>
                    <td><%=compra.getProduto().getNome()%></td>
                    <td><%=compra.getValorTotal()%></td>                    
                    <td>
                        <%
                            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/YYYY");
                            out.print(sdf.format(compra.getDataCompra()));
                        %>                   
                    </td>
                </tr>  
                <%}%>
            </tbody>
        </table>
        <%}%>
    </form>
</div>
<%@include file="../includes/rodape.jsp" %>